﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateTeacher.aspx.cs" Inherits="CMSWCSFSolution.CMS.Views.CreateTeacher"
    Title="CreateTeacher" MasterPageFile="~/Shared/DefaultMaster.master" %>

<asp:Content ID="content" ContentPlaceHolderID="DefaultContent" runat="Server">
    <h1>
        CreateTeacher</h1>
        <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>

<script src="../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>

<script src="../Scripts/jquery-ui-1.8.24.custom.min.js" type="text/javascript"></script>

<link href="../Styles/jquery-ui-1.8.24.custom.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

    $(function () {

        $("#dialog_error").dialog({

            autoOpen: false,

            modal: true

        });

    });

    function showError(msg) {

        $("#dialog_error").prepend(msg);

        $("#dialog_error").dialog("open");

    }

    $(function () {

        $("#dialog_warning").dialog({

            autoOpen: false,

            buttons: {

                Ok: function () {

                    $(this).dialog("close");

                }

            }

        });

    });

    function showWarning(msg) {

        $("#dialog_warning").append(msg);

        $("#dialog_warning").dialog("open");

    }

    function showMsg(ex) {

        ($)(document).ready(function () {

            $("#prompt").append(ex);

            $("#prompt").slideDown();

            setTimeout(function () {

                $("#prompt").fadeOut(3000);

                window.location.href = "TeacherMainPage.aspx";

            }, 4000)

        });

        $("#prompt").mouseover(function () {

            $("#prompt").fadeOut(2000);

            window.location.href = "TeacherMainPage.aspx";

        })

    }

</script>
    <script type="text/javascript">
        function GotoTeacherListPage() {
            window.location.href = "TeacherMainPage.aspx";
            return false;
        }
        function DropdownlistValidation(source, arguments) {
            if (document.getElementById("DropDownListDepartment").value == "Please Select"
                ) {
                arguments.IsValid = false;
            } else {
                arguments.IsValid = true;
            }
        }
        function ClientValidation(source, arguments) {
            var CustomValidator1 = document.getElementById("CustomValidator1");
            var value = document.getElementById("TeacherNameBox").value;
            var patrn = /^[ A-Za-z]*$/; 
            if (value == "") {
                arguments.IsValid = false;
                CustomValidator1.innerText = "Please input name";
            }
            else if (value.length > 10) {
                arguments.IsValid = false;
                CustomValidator1.innerText = " The length of teacherName is not great than 10";
            } else if (!patrn.exec(value)) {
                arguments.IsValid = false;
                CustomValidator1.innerText = " input name is just alphabet";
            }
        }

    </script>
    <style type="text/css">
        .distance
        {
            height: 50px;
            width: 150px;
        }
    </style>
    <fieldset class="bold" id="CreateTeacher">
        <legend>Teacher</legend>
        <table>
            <tr class="distance">
                <td>
                    Teacher Name
                </td>
                <td>
                    <asp:TextBox ID="TeacherNameBox" ClientIDMode="Static" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientIDMode="Static" ErrorMessage="Teacher Name can not be null"
                        ForeColor="Red" ControlToValidate="TeacherNameBox" ValidateEmptyText="true" ClientValidationFunction="ClientValidation"></asp:CustomValidator>
                </td>
            </tr>
            <tr class="distance">
                <td>
                    Teacher Gender
                </td>
                <td height="15px">
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Selected="True">Male</asp:ListItem>
                        <asp:ListItem Selected="False">Female</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class="distance">
                <td>
                    Department
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListDepartment" ClientIDMode="Static" runat="server">
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:CustomValidator ID="CustomValidator2" runat="server" ForeColor="Red" ControlToValidate="DropDownListDepartment"
                        ClientValidationFunction="DropdownlistValidation" ErrorMessage="Department Name  is not valiate"></asp:CustomValidator>
                </td>
            </tr>
            <tr class="distance">
                <td>
                    <asp:Button ID="Button_Create" runat="server" Text="Create New" OnClick="Button_Create_Click" />
                </td>
                <td>
                    <input type="button" value="Cancel" onclick="GotoTeacherListPage();" />
                </td>
            </tr>
        </table>
    </fieldset>
</asp:Content>
